package 线程.demo04;

/**
 * @author wql
 * @version 1.0
 * @date 2022/10/31 15:42
 */

public class Girls implements Runnable{
    private BankCard bankCard;
    public Girls(BankCard bankCard) {
        this.bankCard = bankCard;
    }
    @Override
    public void run() {
            for (int i = 0; i < 5; i++) {
                if (bankCard.getChanges()>=10000){
                bankCard.setChanges(bankCard.getChanges()-10000);
                System.out.println(Thread.currentThread().getName()+"取了10000元，余额为："+bankCard.getChanges());
                 }else {
                    System.out.println("没钱了！！！");
                    i--;
                }
        }
    }
}
